#include <iostream>
#include "DataAccess.hpp"

using namespace std;

using ModuleData::GPSdata;
using ModuleData::GPSsplitter;
using ModuleData::RMC_UTC;
using ModuleData::RMC_FIX_TYPE;
using ModuleData::GPS_RECEIVER_DATA_RECEIVE;


void print_data( void )
{
  const GPSdata& d = ModuleData::instance().get_last_data();

  cout << "\n\n-------------------------\n";
  cout << "type:" << d.get_type() << "\tdata:" << d.get_raw_data() << endl;
  cout << "is_init:" << d.is_init() << "\tis_actived:" << d.is_actived() << endl;

  for (int i = 0; i <= ModuleData::GLL_FIX_TYPE;++i)
    {
      const string *p = static_cast<const string*>( d.get_value( i ) );
      if( p != NULL )
	cout << i << '\t' << *p << endl;
    }
}

void* t_g( int i, const char *s )
{
  printf( "t_g was call!" );
}

int main()
{
  GPSsplitter s;

  ModuleData::instance().add_listener( GPS_RECEIVER_DATA_RECEIVE, print_data );
  ModuleData::instance().monitor();

  while( true )
    {
    }

}
